package me.shibor.study.servlet;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


/**
 * servlet处理表单
 * @author shibor
 *
 */
@WebServlet("/GetPostDemo")
public class GetPostDemo extends HttpServlet {
	private static final long serialVersionUID = 1L;
       


	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		String username = request.getParameter("username");
		String password = request.getParameter("password");
		
		System.out.println("username:" + username + "\n" 
						+"password:" + password);
//		String hobby = request.getParameter("hobby");
//		System.out.println("hobby:\n"+hobby);
		String[] hobbys = request.getParameterValues("hobby");
		for(String temp:hobbys){
			System.out.println("hobby:" + temp);
		}
		//response.sendRedirect("/Servlet-basic/GetPostDemo.html");
		//response.getWriter().append("Served at: ").append(request.getContextPath());
	}


	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
